Photon Mapping
Motivational reference image showcasing complex light interactions through glass and liquid
My motivation for this project stems from the fascinating interplay of light with transparent materials and liquids. The reference image showcases beautiful caustic patterns created when light passes through glass containers filled with colored liquids, creating intricate patterns of focused and scattered light on surrounding surfaces.
This scene demonstrates several interesting physical phenomena:
Reproducing these effects required implementing photon mapping for caustics, properly handling rough dielectric surfaces, and applying advanced denoising techniques to produce clean, production-quality images.
I implemented a complete photon mapping system capable of rendering both caustic and global illumination effects. The implementation follows the approach described in Henrik Wann Jensen's paper with several optimizations:
Initial implementation had ~54% of caustic photons landing on the floor instead of near the glass objects, resulting in wasted computation and poor caustic quality.
Implemented targeted photon emission by:
With only 1M photons, caustics appeared grainy and had visible artifacts.
Increased photon count to 25M and implemented cone filter weighting (k=1.1) for smoother reconstruction. Combined with bilateral denoising in post-processing for production-quality results.
| Parameter | Value | Reasoning |
|---|---|---|
| Caustic Photons | 25,000,000 | High density for smooth, detailed caustics |
| Caustic Radius | 0.010 | Balance between detail and smoothness |
| Cone Filter k | 1.1 | Smooth reconstruction while preserving detail |
| Max Bounces | 10 | Capture multiple refractions through glass/liquid |
Implemented physically-based depth of field by simulating a thin lens camera model. Camera rays are jittered on the aperture plane and directed through the focal plane to create realistic blur.
While depth of field creates beautiful cinematic effects, I ultimately chose to use a pinhole camera (aperture = 0) for the final render to keep all caustic details sharp and clearly visible.
Extended the depth of field implementation to support realistic camera aperture shapes. Implemented hexagonal aperture blade simulation that creates characteristic hexagonal bokeh patterns.
The hexagonal aperture creates realistic bokeh shapes matching real camera lenses with 6-blade apertures. Out-of-focus highlights take on the hexagonal shape of the aperture opening.
Implemented a directional spotlight emitter with cone-shaped emission profile. The spotlight supports:
The spotlight was crucial for efficient photon mapping - by directing photons toward the glass objects, I achieved 95%+ photon utilization compared to 46% with omnidirectional emission.
Integrated Intel's Open Image Denoise (OIDN) library for AI-powered denoising. OIDN uses deep learning models trained on thousands of rendered images to remove Monte Carlo noise while preserving important details.
Intel Open Image Denoise (OIDN) - Version 2.x
Initial implementation crashed due to improper buffer management between Darts image format and OIDN's expected format.
Used OIDN-managed buffers (oidn::BufferRef) instead of raw pointers. Properly copied data between Darts' Image3f format and OIDN's float buffers with correct stride and alignment.
| Configuration | Render Time | Quality |
|---|---|---|
| 256 SPP (No Denoise) | ~8 minutes | Good |
| 32 SPP + OIDN | ~1 minute | Excellent |
OIDN enables 8x faster renders with better quality by reducing required samples per pixel.
Implemented a microfacet-based rough dielectric BSDF using GGX distribution for realistic frosted/translucent glass effects. The implementation includes:
The rough dielectric BSDF was essential for creating the translucent/frosted appearance of the perfume bottle glass, which diffuses light while maintaining transparency.
Implemented bilateral filtering with pixel variance estimation for high-quality denoising. The algorithm performs two independent renders with different random seeds and uses the variance between them to guide adaptive filtering.
| Parameter | Value | Effect |
|---|---|---|
| Spatial Sigma | 2.0 | Controls spatial blur extent |
| Color Sigma | 0.1 | Preserves edges (lower = sharper) |
| Filter Radius | 5 pixels | Neighborhood size |
While OIDN is powerful, bilateral filtering offers:
For my final render, I combined both: OIDN for general noise reduction and bilateral filtering for caustic preservation.
Implemented adaptive search radius that adjusts based on local photon density, ensuring consistent radiance estimates across the image.
Added debug visualization modes to display:
Implemented efficient median-split KD-tree construction with spatial hashing for O(log n) photon queries even with 25M photons.
Final production render combining all implemented features
The final scene depicts a vintage wooden cabinet with two glass containers: a water glass and a decorative perfume bottle filled with pink liquid. A warm spotlight positioned above the objects creates dramatic caustic patterns on the wall and table surface. The caustics show the characteristic focusing patterns created by refraction through curved glass surfaces and liquid interfaces. The perfume bottle uses rough dielectric shading to create a frosted, translucent appearance, while the water glass remains perfectly clear to showcase sharp caustic effects. Bilateral denoising combined with OIDN produces a clean, production-quality result while preserving all fine caustic detail.